package org.esgi.dao;

import java.io.File;
import java.util.List;

import org.esgi.model.interfaces.IForm;
import org.esgi.repository.impl.XMLFormRepository;
import org.esgi.repository.interfaces.IFormRepository;

public class FormDao implements IFormRepository
{
	private static FormDao sharedFormDao_ = null;
	
	private IFormRepository formRepository_;
	
	public static FormDao getSharedFormDao()
	{
		if(FormDao.sharedFormDao_ == null)
			FormDao.sharedFormDao_ = new FormDao();
		return FormDao.sharedFormDao_;
	}
	
	private FormDao() {}
	
	public void setDirectory(File dir)
	{
		this.formRepository_ = new XMLFormRepository(dir);
	}

	@Override
	public List<IForm> getAllForms() 
	{
		return this.formRepository_.getAllForms();
	}

	@Override
	public IForm getFormWithId(String anId) 
	{
		return this.formRepository_.getFormWithId(anId);
	}

	@Override
	public File getFileFormWithId(String anId)
	{
		return this.formRepository_.getFileFormWithId(anId);
	}
	
	@Override
	public Boolean removeForm(IForm aForm) 
	{
		return this.formRepository_.removeForm(aForm);
	}

	@Override
	public Boolean saveForm(IForm aForm) 
	{
		return this.formRepository_.saveForm(aForm);
	}

}
